import akka.actor.Actor
import akka.actor.ActorRef
import akka.actor.ActorSystem
import akka.actor.Props

case class Rumor()
case class Pair(s : Double, w : Double)
case class Dead()
case class SetNeighbours(n : Int, t: Int)
case class Start()
case class LoadedNeighbours()

object Networks 
{
  val LineNetwork = 0
  val GridNetwork = 1
  val FullNetwork = 2
  val ImperfectGridNetwork = 3
}

object Main extends App {	
    val rumorLimit = 10
    
    var nodes = args(0).toInt
    val network = getNetwork(args(1))
    val algorithm = args(2)
    
    if (network == Networks.GridNetwork || network == Networks.ImperfectGridNetwork){
      nodes = Math.sqrt(nodes).toInt
      nodes = nodes * nodes
    }
    
    val nOfActors = nodes
    
    val system = ActorSystem("System")
    val mgr = system.actorOf(Props[Manager], name = "Manager")
    
    var NoOfActorsThatGotMessage = 0
    var startTime = 0.0;
    
    mgr ! Start
    
    system.awaitTermination
	val endTime   = System.currentTimeMillis()
    val totalTime = (endTime - startTime)
    println("Time: " + totalTime + " ms")
    println("No Of Actors That Got Message: " + NoOfActorsThatGotMessage)
    
    def getNetwork(n : String) : Int = {
      if (n == "line") { Networks.LineNetwork }
      else if (n == "2D") { Networks.GridNetwork }
      else if (n == "imp2D") { Networks.ImperfectGridNetwork }
      else { Networks.FullNetwork }
    }
}

